<?php

namespace app\admin\model\finance\extract;

use think\Model;

class taskOut extends Model
{
    // 表名
    protected $name = 'finance_extract_task_otreach';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 追加属性
    protected $append = [
        'status_text',
        'school_text',
        'status_desc',
    ];
    public function setSchollTypeAttr($value,$data)
    {
        return serialize($value);

    }
    public function diskList(){
        return ['8'=>8,'16'=>16,"32"=>32,'64'=>'64','128'=>128,'256'=>256];
    }
    public function getSchollTypeAttr($value,$data)
    {
        return unserialize($value);

    }
    public function setClassTypeAttr($value,$data)
    {
        return serialize($value);

    }  
    public function getClassTypeAttr($value,$data)
    {
        return unserialize($value);

    }
    public function setGradeAttr($value)
    {
        return serialize($value);
    }  
    public function getGradeAttr($value)
    {
        return unserialize($value);
    }

    public function setDisAttr($value)
    {
        return serialize($value);
    } 
    public function getDisAttr($value)
    {
        return unserialize($value);
    }

    public function setShoppingAttr($value)
    {
        return serialize($value);
    }  
    public function getShoppingAttr($value)
    {
        return unserialize($value);
    
    }

    public function setDiskAttr($value)
    {
        return serialize($value);
    }   
    public function getDiskAttr($value)
    {
        return unserialize($value);
    }

    public function setRecharAttr($value)
    {
        return serialize($value);
    }   
    public function getRecharAttr($value)
    {
        return unserialize($value);
    }

    public function setSampleAttr($value)
    {
        return serialize($value);
    }   
    public function getSampleAttr($value)
    {
        return unserialize($value);
    }
/*    'Task.Status 1'  =>  '待提交',
    'Task.Status 2'  =>  '审核失败',
    'Task.Status 3'  =>  '合跑人待审核',
    'Task.Status 4'  =>  '会务待审核',
    'Task.Status 5'  =>  '分公司财务待审核',
    'Task.Status 6'  =>  '分公司负责人待审核',
    'Task.Status 7'  =>  '客户管理部待审核',
    'Task.Status 8'  =>  '客户管理部审核失败',
    'Task.Status 9'  =>  '审核成功',*/
    public function getStatusList()
    {
        return [
            '1' => __('Task.Status 1'),
            '2' => __('Task.Status 2'),
            '3' => __('Task.Status 3'),
            '4' => __('Task.Status 4'),
            '5' => __('Task.Status 5'),
            '6' => __('Task.Status 6'),
            '7' => __('Task.Status 7'),
            '8' => __('Task.Status 8'),
            '9' => __('Task.Status 9'),
            ];
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }
     public function getSchoolTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['school_id'];
        $list = TableField('DataSchool','name',$value);
        return isset($list) ? $list : '';
    }   
    public function getStatusDescAttr($value, $data)
    {        
        $value = $value ? $value : $data['id'];
        $list = TableList('Note',$data['task_id'],'task_id',['ob_id'=>$value],'id','asc');
        $info = '';
        foreach ($list as $k => $v) {
            $info .= '<tr >
                            <td style="text-align: center; vertical-align: middle; ">'.date('Y-m-d H:i:s',$v['createtime']).'</td>
                            <td style="text-align: center; vertical-align: middle; ">'.__('Task.Status '.$v['status'].'').'</td>
                            <td style="text-align: center; vertical-align: middle; ">'.__('Task.Check '.$v['check'].'').'</td>
                            <td style="text-align: center; vertical-align: middle; ">'.$v['username'].'</td>
                            <td style="text-align: center; vertical-align: middle; ">'.$v['desc'].'</td>
                        </tr>';
        }
        return isset($info) ? $info : '';
    }
}
